	var editIndex = undefined;
	function endEditing(tabId){
		if (editIndex == undefined){return true}
		if ($('#'+tabId).datagrid('validateRow', editIndex)){
			//$('#'+tabId).datagrid('getRows')[editIndex]['operaton']= '<a href="javascript:void(0);" onclick="remove1(\''+tabId+'\')">删除</a>';
			$('#'+tabId).datagrid('endEdit', editIndex);
			editIndex = undefined;
			return true;
		} else {
			return false;
		}
	}
	function onClickRow(tabId,index){
		if (editIndex != index){
			if (endEditing(tabId)){
				$('#'+tabId).datagrid('selectRow', index)
						.datagrid('beginEdit', index);
				editIndex = index;
			} else {
				$('#'+tabId).datagrid('selectRow', editIndex);
			}
		}
	}

	function append(tabId){
		if (endEditing(tabId)){
			$('#'+tabId).datagrid('appendRow',{status:'P'});
			editIndex = $('#'+tabId).datagrid('getRows').length-1;
			$('#'+tabId).datagrid('selectRow', editIndex)
					.datagrid('beginEdit', editIndex);
		}
	}
	
	function accept(tabId,datas,url){
			if (endEditing(tabId)){
				doSubmit(url,datas,tabId);
			}
		}
	function saveTransactionTime(tabId,value4){
		$('#'+tabId).datagrid('acceptChanges');
		var row = $('#'+tabId).datagrid('getSelected');
		if (row){
			if(""==row.creditId){
				$("#isAdd").val("true");
			}
			var datas ={isAdd:$("#isAdd").val(),creditId:row.creditId,creditCode:row.creditCode,creditName:row.creditName,creditWeight:row.creditWeight,creditRemark:row.creditRemark};
			accept(tabId,datas,'');
		}
	}

	function editTr(tabId){
		editIndex = $('#'+tabId).datagrid('getRows').length-1;
		$('#'+tabId).datagrid('selectRow', editIndex)
				.datagrid('beginEdit', editIndex);
		$('#'+tabId).datagrid('deleteRow', editIndex+1);
	}
